﻿#parse("partials/header.html") #parse("partials/sidebar.html")
<script>
    jQuery(document).ready(function () {
        var cmd = "${cmd}";
        var doctoridencript = "${Encdoctorid}";
        var scheduleid = "${ScheduleId}";

        $("#divhospital").hide();

        if (cmd == "edit") {
            jQuery("#AppoitmentId").val("0");
            jQuery('#Button1').removeAttr('disabled', 'disabled');
            $("#buttonDelete").show();

            jQuery(".deleteconfirm").live('click', function (event) {
                var deleteid = $(this).attr("deleteid");
              
                DeleteConfirm(deleteid);

            });

            function DeleteConfirm(id) {
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 160,
                    modal: true,
                    buttons: {
                        "Yes": function () {
                            jQuery.ajax({
                                type: "GET",
                                url: "/schedule/doctor/deleteschedule/?id=" + jQuery("#ScheduleId").val(),
                                cache: false,
                                success: function (data) {

                                    window.location = "/schedule/doctor/scheduler/?id=" + doctoridencript;
                                },
                                error: function (data) {
                                },
                                complete: function () {
                                }
                            });
                            $(this).dialog("close");
                        },
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            }

        } else {
            jQuery('#Button1').attr('disabled', 'disabled');
            $("#buttonDelete").hide();
            jQuery("#AppoitmentId").val("0");
        }
        //Submit Form Ajax
        jQuery("#formID").submit(function () {
            if (jQuery("#formID").valid() == true) {
                jQuery.blockUI();

                var post_data = $(this).serialize();
                var form_action = $(this).attr("action");
                var form_method = $(this).attr("method");

                jQuery.ajax({
                    type: form_method,
                    url: form_action,
                    cache: false,
                    dataType: "json",
                    data: post_data,
                    success: function (data) {
                        window.scrollTo(0, 0);
                        jQuery.unblockUI();
                        $("#notif").html(data['strNotification']);
                    },
                    error: function () {

                        alert("Error Occured on Post Ajax");
                        jQuery.unblockUI();
                    },
                    complete: function () {
                    }
                });
            }
            return false;
        });
        setTimePicker();

        $("#cbAppointment").click(function () {

            if ($(this).is(':checked')) {
                jQuery("#StartTime").val("00:00");
                jQuery("#EndTime").val("00:00");
                jQuery("#RoomName").val("");
                jQuery('#StartTime,#EndTime').timepicker('destroy');
                $("#divhospital").show();
                $('#HospitalUnit').attr("Visible", "false");
                $("#divroom").hide();
                jQuery('#Button1').attr('disabled', 'disabled');
                jQuery("#AppoitmentId").val("1");
            } else {
                setTimePicker();
                jQuery('#HospitalUnit').removeAttr('disabled', 'disabled');
                $("#divroom").show();
                $("#divhospital").hide();
                jQuery('#Button1').removeAttr('disabled', 'disabled');
                jQuery("#AppoitmentId").val("0");
            }
        });
    });

    function setTimePicker() {
        var EventStart = $("#StartTime").val();
        var EventEnd = $("#EndTime").val();

        $(".start_time").timepicker({
            ampm: false,
            stepMinute: 5,
            timeFormat: "hh:mm",
            onSelect: function (date) {
                EventStart = date;
            }
        });

        $(".end_time").timepicker({
            ampm: false,
            stepMinute: 5,
            timeFormat: "hh:mm",
            onSelect: function (date) {
                EventEnd = date;
                if (EventEnd <= EventStart) {
                    alert("start time is greater than endtime");
                    jQuery('#buttonAction').attr('disabled', 'disabled');
                    $("#mws-validate-admins").validate({
                        rules: {
                            EndTime: {
                                required: true,
                                date: true
                            }
                        }
                    });
                } else {
                    jQuery('#buttonAction').removeAttr('disabled', 'disabled');
                }
                if (EventEnd != null) {
                    jQuery('#Button1').removeAttr('disabled', 'disabled');
                }
            }

        });
    }
    function OpenSearchRoomPopUp(url) {
        $("#mws-form-dialog").dialog("open");
        var start = jQuery("#StartTime").val();
        var end = jQuery("#EndTime").val();
        var day = jQuery("#DaySet").val();
        var roomname = "";
        $("#modalIframeForm").attr("src", "${rooturl}schedule/doctor/renderavailableroom/?start=" + start + "&end=" + end + "&day=" + day + "&roomname=" + roomname);
        return false;
    }
    function setPresentRoomTextBox(roomid, roomName) {
        $("#HiddenRoomId").val(roomid);
        $("#RoomName").val(roomName);
        $("#mws-form-dialog").dialog("close");

    }
    
   
</script>
<div id="dialog-confirm" title="Delete Confirmation" style="display: none">
    <p>
    </p>
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 5px 7px 20px 40px;">
        </span>Are you sure want to delete this record?</p>
</div>
<div id="mws-container" class="clearfix">
    <div class="container">
        <!-- Panels Start -->
        <form method="post" action="/schedule/doctor/savescheduletoservice/?id=$doctorid"
        class="crud" id="formID">
        <div class="mws-panel grid_8 mws-collapsible">
            <div class="title-caption">
                <h5>
                    $headerinformation - Doctor Schedule</h5>
            </div>
            <div class="mws-panel-header">
                <span class="mws-i-24 i-calendar-today">Add Schedule Doctor</span>
            </div>
            <div class="mws-panel-body">
                <div class="mws-panel-toolbar top clearfix">
                    <ul>
                        <li><a class="mws-ic-16 ic-arrow-left" href="/schedule/doctor/" title="Search">Back
                            To Doctor List</a></li>
                    </ul>
                    <!-- <ul>
                        <li><a class="mws-ic-16 ic-accept" href="#" title="Accept">Add Schedule Doctor</a></li>
                    </ul>-->
                    <!--<ul>
                        <li><a class="mws-ic-16 ic-accept" href="/frontoffice/doctorscheduler/" title="Accept">
                            View Calendar </a></li>
                    </ul>-->
                </div>
                <div id="notif">
                </div>
                <div class="mws-form">
                    <div class="grid_4">
                        <div class="mws-form-inline">
                            <div class="mws-form-row">
                                <label>
                                    Day</label>
                                <div class="mws-form-item">
                                    $ddDays
                                </div>
                            </div>
                            <div class="mws-form-row">
                                <label>
                                    By Appointment</label>
                                <div class="mws-form-item">
                                    <input type="checkbox" name="checkboxappoitment" id="cbAppointment" />
                                </div>
                            </div>
                            <div class="mws-form-row">
                                <div class="mws-form-item large">
                                    <div class="mws-form-cols clearfix">
                                        <div class="mws-form-col-2-8 alpha">
                                            <div class="mws-form-item">
                                                <label>
                                                    Start Time</label>
                                                <input type="text" class="mws-textinput start_time" value="$StartTime" name="StartTime"
                                                    id="StartTime" />
                                            </div>
                                        </div>
                                        <div class="mws-form-col-2-8 alpha">
                                            <div class="mws-form-item">
                                                <label>
                                                    End Time</label>
                                                <input type="text" class="mws-textinput end_time" value="$EndTime" name="EndTime"
                                                    id="EndTime" />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="mws-form-row" id="divroom">
                                <label>
                                    Room</label>
                                <div class="mws-form-item large">
                                    <div class="mws-form-cols clearfix">
                                        <div class="mws-form-col-6-8 alpha">
                                            <div class="mws-form-item">
                                                <input id="RoomName" name="RoomName" type="text" class="mws-textinput" readonly="readonly"
                                                    value="$RoomName" />
                                                <input id="HiddenRoomId" type="hidden" name="HiddenRoomId" value="$HiddenRoomId" />
                                                <input id="HidenDoctorid" type="hidden" name="HidenDoctorid" value="$doctorid" />
                                                <input id="AppoitmentId" type="hidden" name="AppoitmentId" />
                                                <input id="ScheduleId" type="hidden" name="ScheduleId" value="$ScheduleId" />
                                            </div>
                                        </div>
                                        <div class="mws-form-col-2-8 alpha">
                                            <input type="button" id="Button1" addresstype="permanent" name="ButtonSearchPermanentArea"
                                                class="mws-button green small" value="search" onclick="OpenSearchRoomPopUp()" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                              <div class="mws-form-row" id="divhospital">
                                <label>
                                    Hospital</label>
                                <div class="mws-form-item">
                                    $ddHospital
                                </div>
                            </div>
                            <div class="mws-form-row">
                                <label>
                                    Minute Per Slot</label>
                                <div class="mws-form-item">
                                    $ddSlot
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="clear15">
                    </div>
                    <div class="mws-button-row">
                        <input name="buttonAction" id="buttonAction" type="submit" value="Submit" class="mws-button red" />
                        <input name="buttonDelete" id="buttonDelete" type="button" value="Delete" class="mws-button red deleteconfirm" />
                        <input type="reset" value="Reset" class="mws-button gray" />
                    </div>
                </div>
            </div>
        </div>
        </form>
        <!-- Inner Container End -->
    </div>
#parse("partials/footer.html")